package org.zjx.message.messages;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.zjx.message.AbstractMessage;


@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RpcResponse extends AbstractMessage {
    private Object result;
    private Throwable error;
    private String redirectHost;  // 用于主服务器返回Worker地址
    private int redirectPort;     // 用于主服务器返回Worker端口

    public boolean hasError() {
        return error != null;
    }

    public static RpcResponse buildError(Throwable error) {
        RpcResponse response = new RpcResponse();
        response.setError(error);
        return response;
    }
}
